<?php

namespace app\modules\api\controllers;

use Yii;
use yii\web\Controller;
use common\models\Tools;
use \common\models\Works;

/**
 * Default controller for the `api` module
 */
class MyworksController extends Controller
{
    public $enableCsrfValidation = false;
    /**
     * Renders the index view for the module
     * @return string
     */
    public function actionIndex()
    {
        $output = [];
        if (Yii::$app->user->isGuest) {
            $output['success'] = 0;
            $output['msg'] = "未登录，请先登录！";
            Tools::outputjson($output);
            exit;
        }
        $output['success'] = 1;
        $output['msg'] = "请求成功！";
        $userid = Yii::$app->user->identity->id;
        $output['data'] = Works::getUserWorks($userid);
        Tools::outputjson($output);
    }
}
